<template>
  <van-row class="main-menu">
    <van-nav-bar left-text="返回" title="单位看板" @click-left="doBack"/>
    <van-row class="menu-content">
      <van-grid :column-num="3">
        <van-grid-item to='/analysis/dept-grade'>
          <van-icon slot="icon" class-prefix="cspg" name="score-query cspg-color-blue" size="48" />
          <van-row slot="text" class="grid-item-text">评分情况</van-row>
        </van-grid-item>
        <van-grid-item to='/analysis/dept-grade-monitor'>
          <van-icon slot="icon" class-prefix="cspg" name="score-query cspg-color-blue" size="48" />
          <van-row slot="text" class="grid-item-text">评分跟踪</van-row>
        </van-grid-item>
        <van-grid-item to='/analysis/dept-rectify-monitor'>
          <van-icon slot="icon" class-prefix="cspg" name="score-query cspg-color-blue" size="48" />
          <van-row slot="text" class="grid-item-text">整改跟踪</van-row>
        </van-grid-item>
        <van-grid-item to='/analysis/dept-problem-analysis'>
          <van-icon slot="icon" class-prefix="cspg" name="score-query cspg-color-blue" size="48" />
          <van-row slot="text" class="grid-item-text">问题分析</van-row>
        </van-grid-item>
      </van-grid>
    </van-row>
    <!-- <van-dialog style="width: 90%" v-model="showDialog" title="请选择操作部门" show-cancel-button @confirm="doSelectedDept" @cancel="$router.back()" :before-close="verifyOperate">
      <van-radio-group v-model="selectedDept">
        <van-cell-group style="margin-top: 20px" :border="false">
          <card-main-dept
            v-for="(depart) in deptList"
            :key="depart.department_path"
            :department="depart"
            @onClick="startSelectDept(depart)"/>
        </van-cell-group>
      </van-radio-group>
      <van-row style="font-size: 12px;color: red;text-align: center;height:30px; line-height: 30px">{{showError ? '请选择一个部门' : ''}}</van-row>
    </van-dialog> -->
  </van-row>
</template>

<script>
// import CardMainDept from '@/views/common/card/CardMainDept'
export default {
  name: 'DeptIndex',
  // components: { CardMainDept },
  data () {
    return {
      showError: false,
      showDialog: false,
      deptList: [],
      selectedDept: null
    }
  },
  mounted () {
    // if (this.$store.state.authInfo.currentDept) {
    //   return
    // }
    // let list = []
    // if (this.assessType === this.$vo.AssessType.CORP + '') {
    //   list = this.$store.state.authInfo.user.roles.corp.dept.concat(this.$store.state.authInfo.user.roles.corp.assess_dept)
    // } else {
    //   list = this.$store.state.authInfo.user.roles.dept.dept.concat(this.$store.state.authInfo.user.roles.dept.assess_dept)
    // }
    // this.deptList = this.filterRepeat(list, 'department_path')
    // console.log(this.$store.state.authInfo.user.rectify)
    // if (this.deptList.length === 1) {
    //   this.$store.commit('authInfo/setCurrentDept', this.deptList[0])
    // } else {
    //   this.showDialog = true
    // }

    this.$store.commit('authInfo/setCurrentDept', this.$store.state.authInfo.user.rectify[0])
    console.log(this.$store.state.authInfo.currentDept.department_path)
    console.log(this.$store.state.authInfo)
    

  },
  methods: {
    // filterRepeat (arr, prop) {
    //   return arr.filter(function (element, index, self) {
    //     return self.findIndex(el => el[prop] === element[prop]) === index
    //   })
    // },
    // verifyOperate (action, done) {
    //   if (action === 'confirm' && !this.selectedDept) {
    //     this.showError = true
    //     done(false)
    //   } else {
    //     done()
    //   }
    // },
    // startSelectDept (depart) {
    //   this.showError = false
    //   this.selectedDept = depart
    // },
    // doSelectedDept () {
    //   if (this.selectedDept) {
    //     this.$store.commit('authInfo/setCurrentDept', this.selectedDept)
    //   }
    // },
    doBack () {
      // this.$store.commit('authInfo/delCurrentDept')
      this.$router.back()
    }
  }
}
</script>

<style scoped lang="less">
.main-menu{
  background-color: #F9F9F9;
  .menu-content {
    background-color: #FFFFFF;
    .grid-item-text{
      text-align: center;
      font-size: 14px;
      margin: 5px 0px;
    }
  }
}
</style>
